home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg4.cab / test_xmlrpc.py < prev    next >
Text File  |  2005-11-19  |  1KB  |  46 lines

  1. import sys
  2. import unittest
  3. import xmlrpclib
  4. from test import test_support
  5.  
  6. alist = [{'astring': 'foo@bar.baz.spam',
  7.           'afloat': 7283.43,
  8.           'anint': 2**20,
  9.           'ashortlong': 2L,
  10.           'anotherlist': ['.zyx.41'],
  11.           'abase64': xmlrpclib.Binary("my dog has fleas"),
  12.           'boolean': xmlrpclib.False,
  13.           }]
  14.  
  15. class XMLRPCTestCase(unittest.TestCase):
  16.  
  17.     def test_dump_load(self):
  18.         self.assertEquals(alist,
  19.                           xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0])
  20.  
  21.     def test_dump_big_long(self):
  22.         self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,))
  23.  
  24.     def test_dump_bad_dict(self):
  25.         self.assertRaises(TypeError, xmlrpclib.dumps, ({(1,2,3): 1},))
  26.  
  27.     def test_dump_big_int(self):
  28.         if sys.maxint > 2L**31-1:
  29.             self.assertRaises(OverflowError, xmlrpclib.dumps,
  30.                               (int(2L**34),))
  31.  
  32.     def test_dump_none(self):
  33.         value = alist + [None]
  34.         arg1 = (alist + [None],)
  35.         strg = xmlrpclib.dumps(arg1, allow_none=True)
  36.         self.assertEquals(value,
  37.                           xmlrpclib.loads(strg)[0][0])
  38.         self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,))
  39.  
  40. def test_main():
  41.     test_support.run_unittest(XMLRPCTestCase)
  42.  
  43.  
  44. if __name__ == "__main__":
  45.     test_main()
  46.